#ifndef VIDEOBASE_H
#define VIDEOBASE_H

#include "qtimer.h"
#include "touchbutton.h"
#include <QLabel>
#include <QPushButton>
#include <QString>
#include <QWidget>


class VideoBase:public QWidget{
    Q_OBJECT
public:
    virtual void setShowMax(bool newShowMax);
    virtual void setUrl(QString strUrl);
    QString strUrl() const;
    virtual ~VideoBase();
protected:
    VideoBase(QWidget* parent = nullptr);
    virtual void startPlay() = 0;
    virtual void stopVideo(bool bSync)= 0;
    virtual void takePhoto() = 0;
    virtual bool startRecording() = 0;
    virtual bool stopRecording(bool bSync) = 0;
    virtual void setMute(bool bMute) = 0;

    bool isRecording() const { return m_bRecording; }
    bool isPlaying() const{return m_bPlaying;}
    QString makeTimeString(int seconds);
    void initButtons();
    void initStatusContainer();
public slots:
    void onConnectFail();
    void onConnecting();
    void onConnectSucc();
    void onRecordEnd(QString strFile);
    void onTakePhoto(QString strFile);
    void onStopTimer();
    // QWidget interface
protected:
    void resizeEvent(QResizeEvent *event);
    void showEvent(QShowEvent *event);
    void hideEvent(QHideEvent *event);
protected:
    bool m_bShowMax = false;
    bool m_bPlaying = false;
    bool m_bRecording = false;
    TouchButton * m_pPhotoBtn;
    TouchButton * m_pVideoBtn;
    int m_nTestCount = 0;
    QLabel *m_pStatusLabel;
    QWidget* m_pStatusContainer;
    QTimer* m_pReconnectTimer = nullptr;
    TouchButton* m_pReconnectButton = nullptr;
    int m_nReconnectSeconds = 0;
    QLabel * m_pRecordLab;
    QTimer* m_pRecordTimer = nullptr;      // 添加录制计时器
    int m_nRecordSeconds = 0;              // 记录录制时间（秒）
    QString m_strUrl;
    QTimer m_StopTimer; //隐藏时不要立刻停止

};
#endif // VIDEOBASE_H
